from __future__ import annotations

from dataclasses import dataclass


@dataclass
class MultiCraneDistribution:
    loads_kN: list[float]
    max_imbalance_percent: float
    note: str


def distribute_multi_crane(total_load_kN: float, cranes_capacity_kN: list[float], bias_percent: float = 10.0) -> MultiCraneDistribution:
    """多机抬吊负荷分配：按额定能力比例分配，并限制不均衡。"""

    cap_sum = sum(cranes_capacity_kN) or 1.0
    base = [total_load_kN * c / cap_sum for c in cranes_capacity_kN]
    # 允许±bias_percent 的偏差
    max_imb = bias_percent
    return MultiCraneDistribution(loads_kN=base, max_imbalance_percent=max_imb, note="现场需实时监测负荷")


